/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2020-2021.
 * Description: L3 cache header file
 * Author: yanbo <joey.yanbo@huawei.com>
 * Create: 2020-11-19
 */
#ifndef _L3_CACHE_H
#define _L3_CACHE_H

#include "l3_cache_macro.h"

/*
 * this union is defined for P650.
 * but we can use it in hi1381 as well.
 */
typedef union {
#ifdef CONFIG_CPU_BIG_ENDIAN
	struct {
		u32 reserved2 : 16;
		u32 addr_bank : 3;
		u32 addr_high : 5;
		u32 reserved1 : 4;
		u32 mnt_range : 1;
		u32 mnt_type : 2;
		u32 mnt_start : 1;
	} bits;
#else
	struct {
		u32 mnt_start : 1;
		u32 mnt_type : 2;
		u32 mnt_range : 1;
		u32 reserved1 : 4;
		u32 addr_high : 5;
		u32 addr_bank : 3;
		u32 reserved2 : 16;
	} bits;
#endif
	u32 value;
} cache_l3_maint_ctrl;

extern int __init l3cache_init(void __iomem *base, __u32 aux_val);
extern void l3cache_exit(void);

#ifdef CONFIG_L3_CACHE_DEBUG
extern void l3cache_lock_range(phys_addr_t start, phys_addr_t end, u32 way);
extern void l3cache_clean_all(void);
#endif

#endif
